<style>
	table.form_table {
		width:100%;
		margin:auto;
		font-size:14px;
	}
	table.form_table tr td:first-child {
		text-align:left;
		vertical-align:top;
		padding-top:6px;
		width:40%;
	}
</style>
<?=form_open("inventory/add_edit_item/{$item->item_id}", 'id="add_edit_item_form"');?>
<table class="form_table">
	<tr>
		<td>Item Name:</td>
		<td><?=form_input(array('type' => 'text', 'name' => 'item_name', 'value' => $item->item_name))?></td>
	</tr>
	<tr>
		<td>Unit:</td>
		<td><?=form_input(array('type' => 'text', 'name' => 'item_unit', 'value' => $item->item_unit))?></td>
	</tr>
	<tr>
		<td>Whole Sale:</td>
		<td><?=form_input(array('type' => 'text', 'name' => 'item_whole_sale_price', 'value' => $item->item_whole_sale_price))?></td>
	</tr>
	<?if(!$item->item_id):?>
	<tr>
		<td>Quantity:</td>
		<td><?=form_input(array('type' => 'text', 'name' => 'item_quantity', 'value' => $item->item_quantity))?></td>
	</tr>
	<?else:?>
	<tr>
		<td>Retail Price:</td>
		<td><?=form_input(array('type' => 'text', 'name' => 'item_retail_price', 'value' => $item->item_retail_price))?></td>
	</tr>
	<?endif;?>
	<tr>
		<td>Comment:</td>
		<td><?=form_textarea(array('type' => 'text', 'name' => 'activity_comment', 'rows' => '4', 'cols' => '16', 'style' => 'resize:none;overflow:hidden;'))?></td>
	</tr>
</table>
<?=form_close();?>
<script>
	$(function(){
		$('#add_edit_item_form').validate({
			<?if(!$item->item_id):?>
			rules: {
				item_name:'required',
				item_unit: {required:true},
				item_whole_sale_price:{required:true,number:true},
				item_quantity: {required:true,digits:true}
			}
			<?else:?>
			rules: {
				item_name:'required',
				item_unit: {required:true},
				item_whole_sale_price:{required:true,number:true},
				item_retail_price: {required:true,number:true}
			}<?endif;?>,
			submitHandler: function(form) {
	       	    $(form).ajaxSubmit(function(response) {
	       	    	inv_pagination_init();
					$(form).parents('.ui-dialog-content').dialog('close');
				});
			}
		});
	});
</script>